package org.example.jiap.bk.model.pojo;


import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
public class ResultPOJO<T> {
    //业务状态 0-成功  1-失败
    private Integer code;
    //提示信息
    private String message;
    //相应数据
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    //快速返回操作成功响应结果(带响应数据)
    public static <E> ResultPOJO<E> success(E data) {
        return new ResultPOJO<>(0,"操作成功",data);
    }

    //快速返回操作成功响应结果
    public static ResultPOJO success() {
        return new ResultPOJO(0, "操作成功", null);
    }

    public static ResultPOJO error(String message) {
        return new ResultPOJO(1, message, null);
    }
}
